/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package n64Controller;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.util.EnumMap;
import n64Controller.N64Controller.ButtonEvent;
import n64Controller.N64Controller.MoveEvent;

/**
 *
 * @author marcos
 */
public class N64ControllerPanel extends javax.swing.JPanel {

    /**
     * Creates new form N64ControllerPanel
     */
    public N64ControllerPanel() {
        initComponents();
        calibrate();
        setToogleButton();
        setAnalogKind();
        setTurbo();
    }

    protected void updateTable() {
        EnumMap<N64Controller.Button, Integer> buttonMap = n64CImagePanel.getController().getButtonMap();
        int i = 0;
        for (N64Controller.Button b : buttonMap.keySet()) {
            jTableMap.getModel().setValueAt(b, i, 0);
            jTableMap.getModel().setValueAt(KeyEvent.getKeyText(buttonMap.get(b)), i, 1);
            ++i;
        }
        //status("Button mapping updated.");
    }

    private void calibrate() {
        int amaxx = (Integer) jTableCalibration.getModel().getValueAt(0, 0);
        int amaxy = (Integer) jTableCalibration.getModel().getValueAt(0, 1);
        int aminx = (Integer) jTableCalibration.getModel().getValueAt(1, 0);
        int aminy = (Integer) jTableCalibration.getModel().getValueAt(1, 1);
        int dmaxx = (Integer) jTableCalibration.getModel().getValueAt(2, 0);
        int dmaxy = (Integer) jTableCalibration.getModel().getValueAt(2, 1);
        int dminx = (Integer) jTableCalibration.getModel().getValueAt(3, 0);
        int dminy = (Integer) jTableCalibration.getModel().getValueAt(3, 1);
        double incr = Double.parseDouble(jTextFieldIncrRatio.getText());
        getController().calibrate(new Point(amaxx, amaxy), new Point(aminx, aminy),
                new Dimension(dmaxx, dmaxy), new Dimension(dminx, dminy));
        getController().setIncrementRatio(incr);
        //status("Controller calibrated.");
    }

    private void setAnalogKind() {
        N64Controller.Analog k = null;
        switch ((String) jComboBoxAnalogKind.getSelectedItem()) {
            case "Incremental mouse":
                k = N64Controller.Analog.INCREMENTAL_MOUSE;
                break;
            case "Absolute mouse":
                k = N64Controller.Analog.ABSOLUTE_MOUSE;
                break;
            case "Map to keys":
                k = N64Controller.Analog.MAP_KEYS;
                break;
        }
        getController().setAnalogKind(k);
        //status("Controller analog kind changed.");
    }

    private void setToogleButton() {
        if ("<none>".equals(jComboBoxToogleButton.getSelectedItem())) {
            getController().disableToogleButton();
            //status("Toogle button disabled.");
        } else {
            getController().setToogleButton(N64Controller.Button.valueOf((String) jComboBoxToogleButton.getSelectedItem()));
            //status("Toogle button changed.");
        }
    }

    private void setTurbo() {
        if (jCheckBoxTurbo.isSelected()) {
            jTextFieldTurboDelay.setEnabled(true);
            int delay = Integer.parseInt(jTextFieldTurboDelay.getText());
            getController().enableTurbo(delay);
            //status("Turbo is enabled with delay " + delay + ".");
        } else {
            jTextFieldTurboDelay.setEnabled(false);
            getController().disableTurbo();
            //status("Turbo is disabled.");
        }
    }

    private void setControllerListener() {
        boolean addEventListener = getController().addEventListener(new N64Controller.N64ControllerEventListener() {

            @Override
            public void buttonPressed(ButtonEvent evt) {
            }

            @Override
            public void buttonReleased(ButtonEvent evt) {
            }

            @Override
            public void moved(MoveEvent evt) {
                jTableCalibration.getModel().setValueAt((Integer) evt.analogValue.x, 4, 0);
                jTableCalibration.getModel().setValueAt((Integer) evt.analogValue.y, 4, 1);
            }
        });
    }

    public N64Controller getController() {
        return n64CImagePanel.getController();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanelMapping = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTableMap = new javax.swing.JTable();
        n64CImagePanel = new n64Controller.N64CImagePanel();
        jPanelCalibration = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTableCalibration = new javax.swing.JTable();
        jButtonCalibrate = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldIncrRatio = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jTextFieldTurboDelay = new javax.swing.JTextField();
        jCheckBoxTurbo = new javax.swing.JCheckBox();
        jLabel9 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jComboBoxAnalogKind = new javax.swing.JComboBox();
        jComboBoxToogleButton = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();

        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                formComponentShown(evt);
            }
        });

        jPanelMapping.setBorder(javax.swing.BorderFactory.createTitledBorder("Button mapping"));

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

        jTableMap.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"", null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null},
                {null, null}
            },
            new String [] {
                "Button", "Key"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.Integer.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jTableMap);

        n64CImagePanel.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                n64CImagePanelKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jPanelMappingLayout = new javax.swing.GroupLayout(jPanelMapping);
        jPanelMapping.setLayout(jPanelMappingLayout);
        jPanelMappingLayout.setHorizontalGroup(
            jPanelMappingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelMappingLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(n64CImagePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanelMappingLayout.setVerticalGroup(
            jPanelMappingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelMappingLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanelMappingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(n64CImagePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 314, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanelCalibration.setBorder(javax.swing.BorderFactory.createTitledBorder("Calibration"));

        jLabel2.setText("Analog value - max:");

        jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

        jTableCalibration.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                { new Integer(80),  new Integer(80)},
                { new Integer(-80),  new Integer(-80)},
                { new Integer(2),  new Integer(2)},
                { new Integer(-2),  new Integer(-2)},
                {null, null}
            },
            new String [] {
                "x", "y"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.Integer.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jTableCalibration.setRowHeight(20);
        jScrollPane2.setViewportView(jTableCalibration);

        jButtonCalibrate.setText("Calibrate");
        jButtonCalibrate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCalibrateActionPerformed(evt);
            }
        });

        jLabel3.setText("Analog value - min:");

        jLabel4.setText("Analog deadzone - max:");

        jLabel5.setText("Analog deadzone - min:");

        jLabel6.setText("Mouse increment ratio:");

        jTextFieldIncrRatio.setText("1");

        jLabel1.setText("Actual analog value:");

        javax.swing.GroupLayout jPanelCalibrationLayout = new javax.swing.GroupLayout(jPanelCalibration);
        jPanelCalibration.setLayout(jPanelCalibrationLayout);
        jPanelCalibrationLayout.setHorizontalGroup(
            jPanelCalibrationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCalibrationLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelCalibrationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanelCalibrationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jTextFieldIncrRatio, javax.swing.GroupLayout.DEFAULT_SIZE, 64, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(jButtonCalibrate)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanelCalibrationLayout.setVerticalGroup(
            jPanelCalibrationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelCalibrationLayout.createSequentialGroup()
                .addGroup(jPanelCalibrationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanelCalibrationLayout.createSequentialGroup()
                        .addGap(42, 42, 42)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel1))
                    .addGroup(jPanelCalibrationLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelCalibrationLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jTextFieldIncrRatio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonCalibrate))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Turbo"));

        jTextFieldTurboDelay.setColumns(5);
        jTextFieldTurboDelay.setText("0");
        jTextFieldTurboDelay.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldTurboDelayActionPerformed(evt);
            }
        });
        jTextFieldTurboDelay.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                jTextFieldTurboDelayFocusLost(evt);
            }
        });

        jCheckBoxTurbo.setText("Enable turbo");
        jCheckBoxTurbo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBoxTurboActionPerformed(evt);
            }
        });

        jLabel9.setText("Delay [ms]:");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jCheckBoxTurbo)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel9)
                        .addComponent(jTextFieldTurboDelay, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jCheckBoxTurbo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextFieldTurboDelay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Mouse"));

        jLabel8.setText("Toogle mouse on/off button:");

        jComboBoxAnalogKind.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Incremental mouse", "Absolute mouse", "Map to keys" }));
        jComboBoxAnalogKind.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxAnalogKindActionPerformed(evt);
            }
        });

        jComboBoxToogleButton.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "<none>", "A", "B", "Z", "START", "D_UP", "D_DOWN", "D_LEFT", "D_RIGHT", "L", "R", "C_UP", "C_DOWN", "C_LEFT", "C_RIGHT", "A_UP", "A_DOWN", "A_LEFT", "A_RIGHT" }));
        jComboBoxToogleButton.setSelectedItem("L");
        jComboBoxToogleButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxToogleButtonActionPerformed(evt);
            }
        });

        jLabel7.setText("Analog kind:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addComponent(jLabel7)
                    .addComponent(jComboBoxAnalogKind, 0, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jComboBoxToogleButton, 0, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBoxAnalogKind, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBoxToogleButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanelMapping, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanelCalibration, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanelCalibration, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addComponent(jPanelMapping, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void n64CImagePanelKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_n64CImagePanelKeyPressed
        updateTable();
    }//GEN-LAST:event_n64CImagePanelKeyPressed

    private void jButtonCalibrateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCalibrateActionPerformed
        calibrate();
    }//GEN-LAST:event_jButtonCalibrateActionPerformed

    private void jTextFieldTurboDelayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldTurboDelayActionPerformed
        setTurbo();
    }//GEN-LAST:event_jTextFieldTurboDelayActionPerformed

    private void jTextFieldTurboDelayFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextFieldTurboDelayFocusLost
        setTurbo();
    }//GEN-LAST:event_jTextFieldTurboDelayFocusLost

    private void jCheckBoxTurboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxTurboActionPerformed
        setTurbo();
    }//GEN-LAST:event_jCheckBoxTurboActionPerformed

    private void jComboBoxAnalogKindActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxAnalogKindActionPerformed
        setAnalogKind();
    }//GEN-LAST:event_jComboBoxAnalogKindActionPerformed

    private void jComboBoxToogleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxToogleButtonActionPerformed
        setToogleButton();
    }//GEN-LAST:event_jComboBoxToogleButtonActionPerformed

    private void formComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentShown
        setControllerListener();
        updateTable();
    }//GEN-LAST:event_formComponentShown
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonCalibrate;
    private javax.swing.JCheckBox jCheckBoxTurbo;
    private javax.swing.JComboBox jComboBoxAnalogKind;
    private javax.swing.JComboBox jComboBoxToogleButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanelCalibration;
    private javax.swing.JPanel jPanelMapping;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTableCalibration;
    private javax.swing.JTable jTableMap;
    private javax.swing.JTextField jTextFieldIncrRatio;
    private javax.swing.JTextField jTextFieldTurboDelay;
    private n64Controller.N64CImagePanel n64CImagePanel;
    // End of variables declaration//GEN-END:variables
}
